package org.test.web.controller;

import java.util.function.IntBinaryOperator;
import java.util.function.IntPredicate;

/**
 * 功能描述
 *
 * @author: weiken
 * @date: 2024年05月06日 9:49
 */
public class LambdaDemo01 {
    public static void main(String[] args) {
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                System.out.println("新线程run被执行");
//            }
//        }).start();

//        new Thread(()->{
//            System.out.println("新线程run被执行");
//        }).start();

//        int i = calculateNum((int left, int right)->{
//            return left+right;
//        }
//        );
//
//        System.out.println(i);

        printNum((int value)->{
            return value%2==0;
        });

    }

    public static int calculateNum(IntBinaryOperator operator){
        int a=10;
        int b=20;
        return operator.applyAsInt(a,b);
    }

    public static void printNum(IntPredicate predicate){
        int[] arr={1,2,3,4,5,6,7,8,9,10};
        for (int i : arr) {
            if(predicate.test(i)){
                System.out.println(i);
            }
        }
    }
}
